package com.swordliu.facebook.controller.base;

import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;

import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

/**
 * controller support
 * Created by SwordLiu on 2017-07-03.
 */
public class BaseController {

//    private HttpServletRequest request;
//
//    static {
//        if(request == null)
//            request = getRequest();
//    }

    public HttpServletRequest getRequest() {
        return ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
    }

    public HttpSession getSession() {
        return getRequest().getSession();
    }

    public ServletContext getApplication() {
        return getRequest().getServletContext();
    }



}
